export default {
	namespace: true,
	state: {
		theme: 'pink',
		tabActive: '',
		tabList: [],
		tipsArr: [],

		// 登录模块
		cutDown: 60, // 倒计时
		cutDownTimer: null, // 定时器

		// 收货地址列表
		expressList: [],

		// 优惠券列表
		couponList: [],
		isShow: false,

		showTabbar: true, // tab页面是否显示tabb栏目
	},
	mutations: {
		changeTheme(state, theme) {
			let arr = ['pink', 'blue', 'green'];
			arr = arr.filter(item => item != theme);
			let num = Math.floor(Math.random() * arr.length);
			state.theme = arr[num];
		},
		changeTabActive(state, val) {
			state.tabActive = val;
		},
		changeTabberAction(state, list) {
			state.tabList = list;
		},
		// 登录模块
		changeDownTimer(state, val) {
			if (!val) return;
			if (val === 'clear') {
				clearInterval(state.cutDownTimer);
				state.cutDownTimer = null;
				state.cutDown = 60;
			} else {
				state.cutDownTimer = setInterval(() => {
					if (state.cutDown) {
						state.cutDown = state.cutDown - 1;
					} else {
						state.cutDown = 60;
						clearInterval(state.cutDownTimer);
						state.cutDownTimer = null;
					}
				}, 1000);
			}
		},
		changeExpressList(state, list) {
			state.expressList = list || [];
		},
		changeCouponList(state, list) {
			state.couponList = list || [];
		},
		changeNoticeNum(state, list) {
			state.tipsArr = list || [];
		},
		changeIsShow(state,flag) {
			state.isShow = flag;
		},
		changeShowTabbar(state,flag) {
			state.showTabbar = flag;
		}
	}
}